package com.swanclouds.redfish.sessions.domain;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.swanclouds.model.sessions.Session;
import com.swanclouds.redfish.common.redfish.MemberModel;
import com.swanclouds.redfish.common.redfish.Status;

import java.util.Map;

/**
 * @author 张立强
 * @version jdk1.8.0
 */
public class SessionConcrete implements Session {
    /**
     * 系统资源的访问路径
     */
    @JsonProperty("@odata.id")
    private String dataId;

    /**
     * 系统资源模型的OData描述信息
     */
    @JsonProperty("@odata.context")
    private String context;

    /**
     * 系统资源的类型
     */
    @JsonProperty("@odata.type")
    private String type;

    /**
     * 系统资源的ID
     */
    @JsonProperty("Id")
    private String id;

    /**
     * 系统资源的名称
     */
    @JsonProperty("Name")
    private String name;

    @JsonProperty("SessionTimeout")
    private Integer timeout;

    @JsonProperty("ServiceEnabled")
    private Boolean ServiceEnabled;

    @JsonProperty("Sessions")
    private MemberModel sessions;

    @JsonProperty("Status")
    private Status status;

    @JsonProperty("Oem")
    private Map<String,Object> oem;

    /**
     * 集合资源的访问路径 @odata.id
     * @return dataId
     */
    @Override
    public String getDataId() {
        return this.dataId;
    }

    /**
     * 集合资源模型的描述信息 @odata.context
     * @return context
     */
    @Override
    public String getContext() {
        return this.context;
    }

    /**
     * 集合资源的类型 @odata.type
     * @return type
     */
    @Override
    public String getType() {
        return this.type;
    }

    /**
     * 资源名称 Name
     * @return name
     */
    @Override
    public String getName() {
        return this.name;
    }

    @Override
    public Integer getSessionTimeout() {
        return this.timeout;
    }

    @Override
    public String getSessions() {
        return this.sessions.getDataId();
    }

    public Status getStatus() {
        return this.status;
    }

    public Map<String, Object> getOem() {
        return this.oem;
    }

    @Override
    public String toString() {
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            return objectMapper.writeValueAsString(this);
        } catch (JsonProcessingException e) {
        }
        return "SessionConcrete {" +
                "dataId='" + dataId + '\'' +
                ", context='" + context + '\'' +
                ", type='" + type + '\'' +
                ", id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", timeout=" + timeout +
                ", ServiceEnabled=" + ServiceEnabled +
                ", sessions=" + sessions +
                ", status=" + status +
                ", oem=" + oem +
                '}';
    }
}
